<%@ page import="com.googlecode.monitoring.flash.model.FlashItemToCheck" %>
<%@ page import="com.googlecode.monitoring.model.StateName" %>

<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<jsp:useBean id="settings" scope="request" type="com.googlecode.monitoring.web.SettingsBean"/>
<jsp:useBean id="flashStatistic" scope="request" type="com.googlecode.monitoring.dao.StatisticDao"/>
<jsp:useBean id="dbAgentStatusBean" scope="request" type="com.googlecode.monitoring.web.DbAgentStatusBean"/>
<jsp:useBean id="wsAgentStatusBean" scope="request" type="com.googlecode.monitoring.web.WsAgentStatusBean"/>
<jsp:useBean id="flashAgentStatusBean" scope="request" type="com.googlecode.monitoring.web.FlashAgentStatusBean"/>
<jsp:useBean id="flashItems" scope="request" type="java.util.List<com.googlecode.monitoring.flash.model.FlashItemToCheck>"/>

<html>
<head>
    <title>${title}</title>
    <style type="text/css" media="all">@import "styles/main.css";</style>
    <jsp:include page="autoRefreshHeader.jsp"/>
</head>
<body>

<jsp:include page="monitoringSummary.jsp"/>

<div class="singlePanel">

    <h2>Flash Monitoring</h2>


    <%

        if (dbAgentStatusBean.isDataFound()) {

    %>

    <table>
        <tr>
            <th>Page name</th>
            <th>Description</th>
            <th>State</th>
            <th>Statistic</th>
            <th>Last Check</th>
            <th>Next Check</th>
        </tr>


        <%

            for (FlashItemToCheck flashItemToCheck : flashItems) {
        %>
        <tr <%=flashItemToCheck.getCurrentStateName().equals(com.googlecode.monitoring.model.StateName.EMAIL_SENT) ? "class=\"stateBad\"" : ""%>>
            <td class="nowrap">
                <%=flashItemToCheck.getName()%>
            </td>
            <td>
                <%=flashItemToCheck.getDescr()%>
            </td>
            <td class="nowrap">
                <%=flashItemToCheck.getCurrentStateName().equals(com.googlecode.monitoring.model.StateName.EMAIL_SENT) ? "OUTDATED" : "up to date"%>
            </td>
            <td>
                <%=flashStatistic.getPercentageUptimeForLastDays(flashItemToCheck.getId(), 30)%>
            </td>
            <td><%=flashItemToCheck.getLastCheckTime()%>
            <td><%=flashItemToCheck.getNextCheckTime()%>
        </tr>
        <%
            }

        %>
    </table>

    <%

        }

    %>
</div>

</body>
</html>